import { Component, OnInit } from '@angular/core';
import { MdDialog } from '@angular/material';
import { NewProjectComponent } from '../new-project/new-project.component';
import { InviteComponent } from '../invite/invite.component';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';

@Component({
  selector: 'app-project-list',
  templateUrl: './project-list.component.html',
  styleUrls: ['./project-list.component.scss']
})
export class ProjectListComponent implements OnInit {
  projects = [
    {
      'name': '企业协作平台',
      'desc': '企业内部协作平台项目',
      'coverImg': 'assets/images/covers/0.jpg'
    },
    {
      'name': 'CRM管理系统',
      'desc': '企业内部协作平台项目',
      'coverImg': 'assets/images/covers/1.jpg'
    }
  ];

  constructor(private dialog: MdDialog) {
  }

  ngOnInit() {
  }

  openNewProjectDialog() {
    const dialogRef = this.dialog.open(NewProjectComponent, {
      data: {title: '新建项目'},
      width: '500px',
      height: '350px',
      position: {top: '65px'}
    });

    dialogRef.afterClosed().subscribe(result => console.log(result));

  }

  launchInviteDialog() {
    const dialogRef = this.dialog.open(InviteComponent);
  }

  launchEditDialog() {
    const dialogRef = this.dialog.open(NewProjectComponent, {data: {title: '编辑项目'}});
  }

  launchDeleteDialog() {
    const dialogRef = this.dialog.open(ConfirmDialogComponent, {data: {title: '删除项目', content: '您确认删除改项目吗？'}});
    dialogRef.afterClosed().subscribe(result => console.log(result));
  }
}
